<!DOCTYPE html>
<html>
<head>
<#include "/common/freemarker/include_css.ftl">
<title>用户编辑</title>
</head>


<body>
	<div class="panel panel-default">
	   <div class="panel-heading">
	       <div class="panel-title">用户编辑</div>
	   </div>
	   <div clas="panel-body">
	      <div class="row">
	           <div class="col-md-10">
	               <br>
	               <form id="contentForm" class="form-horizontal"  action="<@context/>ea/user/save.do" method="POST"  >
	                	<input type="hidden" name="id" value='<#if obj?exists>${obj.id?if_exists}</#if>' />
						 
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">用户姓名<font color="red"> *</font></label>
	                        <div class="col-md-8">
								<input type="text"  class="input-sm form-control required" id="name" name="name" value='<#if obj?exists>${obj.name?if_exists}</#if>'    minlength="2"  />
	                    	</div>              	
	                    </div> 
	                      
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">登录账号<font color="red"> * </font></label>
	                        <div class="col-md-8">
								<input type="text"  class="input-sm form-control required" id="account" name="account" value='<#if obj?exists>${obj.account?if_exists}</#if>'      />
	                    	</div>              	
	                    </div> 
	                    <#if obj?exists==false>
		                    <div class="form-group">
		                    	<label class="col-md-2 control-label">登录密码<font color="red">  </font></label>
		                        <div class="col-md-8">
									<input type="password"  class="input-sm form-control  password" id="passwd" name="passwd" value='<#if obj?exists>${obj.passwd?if_exists}</#if>'      />
		                    	</div>              	
		                    </div>
	                    </#if>
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">性别<font color="red">  </font></label>
	                        <div class="col-md-8">
								<select class="form-control m-b" name="sex" id="sex" >
			                   		 <option value="">请选择</option>
			                        <option value="男">男</option>
			                        <option value="女">女</option>
			                    </select>
			                    <#if rhs["obj"]?exists && rhs["obj"].sex?exists>
			                    	<script>
			                    		$("#sex").val("${rhs["obj"].sex}");
			                    	</script>
			                    </#if>
	                    	</div>              	
	                    </div> 
	                    
					   <div class="form-group">
		                	 <label  class="col-sm-2 control-label" for="">生日<font color="red"> </font> </label>
		                     <div class="col-md-8">
			                     <div class="input-group col-md-5  col-xs-6">  
			                   		 <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
			               			 
			               			 <input type="text" class="input-sm form-control" id="birthDate" name="birthDate" value='<#if rhs["obj"]?exists && rhs["obj"].birthDate?exists>${rhs["obj"].birthDate?string("yyyy-MM-dd")}</#if> ' onclick="javascript:WdatePicker({dateFmt:'yyyy-MM-dd'});"  />
								</div>
		               		 </div>
		                </div>
	                	                    
	                    	                    
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">手机号码<font color="red">  </font></label>
	                        <div class="col-md-8">
								<input type="text"  class="input-sm form-control   digits" id="phoneNumber" name="phoneNumber" value='<#if obj?exists>${obj.phoneNumber?if_exists}</#if>'  />
	                    	</div>              	
	                    </div> 
	                    
	                    <div class="form-group">
	                    	<label class="col-md-2 control-label">email<font color="red">  </font></label>
	                        <div class="col-md-8">
								<input type="text"  class="input-sm form-control   email" id="email" name="email" value='<#if obj?exists>${obj.email?if_exists}</#if>'  />
	                    	</div>              	
	                    </div> 
	                  
				        <div class="form-group">
				            <label class="col-sm-2 control-label">是否失效：</label>
				            <div class="col-sm-8">   
				              	<span  class="checkbox i-checks">
					              	<label><input name="disabled" type="checkbox" id="disabled"  value="1" <#if  obj?exists && obj.disabled?exists && obj.disabled == 1>checked</#if> /></label>
					            </span>
				            </div>
				        </div>
	                     <#if obj?exists >
	                     	<#assign rolesInfos= obj.getRolesInfo()>
	                     	<#assign roleIds= rolesInfos[0]>
	                     	<#assign roleNames= rolesInfos[1]>
	                     </#if>
				         <div class="form-group">
				            <label class="col-sm-2 control-label">关联角色：</label>
				            <div class="col-sm-8">
			          			  	<div class="input-group"> 
					  			  		<input type="hidden" name="roleIds" id="roleIds" value='${roleIds?if_exists}'>
					  			  		<input type="hidden" name="oldRoleIds" id="oldRoleIds" value='${roleIds?if_exists}'>
			              				<input type="text"  class="form-control" name="roleNames" id="roleNames" readonly="readonly" value="${roleNames?if_exists}">
								  		<span class="input-group-btn">
											<INPUT type="button" value="选 择" id="btnSelect" name="btnSelect" class="btn btn-secondary  btn-default" onclick="selectRole('roleIds','roleNames','true','false')">
					                   	 </span>
									</div>
				            </div>
				        </div>
	                                         
	                    <div class="form-group">
	                    	<div class="col-md-offset-2 col-md-8">
	                    		<input type="button" class="btn btn-sm  btn-primary" id="submitBtn" value="保 存"/>
	                    		<input type="button" class="btn btn-sm btn-default" value="返 回" onclick="javascript:history.go(-1)"/>
	                    	</div>
	                    </div>
	              </form>
	        </div>
	    </div>
	</div>
	<#--  公共js -->
	<#include "/common/freemarker/include_js.ftl">
	<#--  页面自己的js -->
	<script type="text/javascript" src="<@context/>common/ckeditor_4.5.4_full/ckeditor/ckeditor.js"></script>
	 
 
	 
  
	<script>
	    
		 $("#submitBtn").click(function() {
			  if(!$("#contentForm").valid()){
			    	 return;
			  }
			
			  $.ajax({
			         type:"POST",
			         url: "<@context/>ea/user/beforSaveCheck.do",
			         data: $('#contentForm').serialize(),
			         dataType: 'json',
			         async: false,
			         cache: false,
			         success: function(json){
			        	if (json.status!="success"){
			        		alert(json.message);
			        		$("#account").focus(); 
			        	}else{
			        		$("#submitBtn").attr("value", "提交中..."); 
						    $('#contentForm').find(":button").attr("disabled", true);
						    $("#contentForm").submit(); //提交表单，如果不写，即便通过表单也不会自动提交 
			        	}
			         } ,
			         error:function(err){
			         	alert("出错啦");
			         }
			  }); 
				 

		})
 
	</script>
 
</body>
</html>

 

